﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GameSite.Models
{
    public class NewsCategoryModel
    {
        private Dictionary<NewsCategory, string> dispNames =
                        new Dictionary<NewsCategory, string>() {
                            {NewsCategory.AllNotice, "所有公告" },
                            {NewsCategory.GameNotice, "游戏公告" },
                            {NewsCategory.ActivityNotice, "活动公告"}
                        };

        public NewsCategoryModel(GameA4Context context, int id)
        {
            ID = id;

            var newsDispViewModel = new List<NewsDispViewModel>();
            IEnumerable<GameNew> gamenews = new List<GameNew>();
            IEnumerable<Activity> activities = new List<Activity>();
            switch (id)
            {
                case 0:
                    gamenews = context.GameNews.GetDispList().Take(10);
                    activities = context.Activities.GetDispList().Take(10);
                    break;
                case 1:
                    gamenews = context.GameNews.GetDispList();
                    break;
                case 2:
                    activities = context.Activities.GetDispList();
                    break;
                default:
                    break;
            }

            GameNews = gamenews.ToList();
            Activities = activities.ToList();
        }

        public int ID { get; private set; }
        public IEnumerable<GameNew> GameNews { get; private set; }
        public IEnumerable<Activity> Activities { get; private set; }

        public NewsCategory CategoryName
        {
            get
            {
                return (NewsCategory)Enum.Parse(typeof(NewsCategory), Convert.ToString(ID));
            }
        }

        public string CategoryDispName
        {
            get
            {
                return dispNames[CategoryName];
            }
        }
    }
}